import request from '../request'

async function addAdv(payload){
    return await request.post('/addAdv',payload)
}
/**
 * 获取广告列表
 */
async function getAdvList(pageIndex,keyword=''){
    return await request.get('/advList',{params:{keyword,pageIndex}})
}
async function getById(_id){
    return await request.get('/advList/' + _id) // params参数
}
/**
 * 编辑操作api     后台接口  advListModel.updateOne({_id},payload)
 */
async function editAdv(payload,_id){
    // 虽然添加和编辑请求的都是同一个后台接口 /addAdv 但是编辑操作有query参数 _id
    return await request.post('/addAdv',payload,{params:{_id}})
}

async function deleteAdv(_id){
    return await request.delete('/advList/' + _id)
}

export default{
    addAdv,
    getAdvList,
    getById,
    editAdv,
    deleteAdv
}